<template>
  <div class="rob_record">
    <div class="top_box">
      <Button type="primary" @click="exportBtn(1)" v-if="unlocking('0101050602')" style="margin-right: 10px">
        全号导出
      </Button>
      <Button type="primary" @click="exportBtn(0)" v-if="unlocking('0101050601')">导出</Button>
    </div>

    <dt-grid ref="table" :onFetch="onFetch" :page="page" />
  </div>
</template>

<script>
  import Column from './opt/columns.js'
  import publicCustomer from '@/biz/customer/publicCustomer'

  export default {
    name: 'DtManagementRobRecord',

    data() {
      return {
        page: {
          total: 0
        },
        params: {}
      }
    },

    mounted() {
      this.$refs.table.init(this, new Column(this))
      this.$refs.table.fetch()
    },

    methods: {
      onFetch(info) {
        this.params = {
          ...info,
          buildingId: this.$dt.buildInfo().housesId
        }
        return publicCustomer.buildingPoolRecordPage(this.params).then((res) => {
          console.log('请求数据', res)
          this.page.total = res.total
          return res.records
        })
      },
      exportBtn(val) {
        this.params.maskCustomerPhone = val
        publicCustomer.buildingPoolRecordExport(this.params).then((res) => {
          console.log('导出', res)
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .rob_record {
    padding: 24px;
  }
  .top_box {
    text-align: right;
    padding-right: 16px;
  }
</style>
